package IO;

import java.io.UnsupportedEncodingException;
import java.util.Arrays;

public class Code {
    public static void main(String[] args) throws UnsupportedEncodingException {
        String value=System.getProperty("file.encoding");
        System.out.println("系统默认编码"+value);
        String str="中文";
        byte[]bytes=str.getBytes();//使用平台的默认字符集将此string编码为byte序列，并将结果储存到一个新的byte数组中
        byte[]bytes1=str.getBytes("GBK");
        byte[]bytes2=str.getBytes("utf-8");
        System.out.println(Arrays.toString(bytes));
        System.out.println(Arrays.toString(bytes1));
        System.out.println(Arrays.toString(bytes2));

        String str2=new String(bytes2,"utf-8");
        System.out.println(str2);

        str2=new String(bytes1,"GBK");
        System.out.println(str2);



    }
}
